How to be a hacker

A intro to the command line for grad students

Jim Rose

Nov 30 2022

Let’s take a second to appreciate the view

So far this semester (whether you realize it or not) you’ve learned THREE DIFFERENT data analysis languages

  • R
  • Markdown
  • Statistics (not really programming, but certainly an esoteric language!)

Now let’s take a peak at one more: Unix

What is Unix?

Unix is the programming language that underpins the operating system of any computer running either macOS or linux.

Somewhat synomymous terms:

  • Command line
  • Terminal
  • Bash
  • Linux

Why learn unix?

  • To interact more directly with your computer
    • Or to work with remote servers
  • To work with LARGE files (i.e. genetic sequencing data)
    • If it fits on your computer you can manipulate it with unix
    • In R you are limited by what you can load into RAM memory

File Manipulation

Command Example Detail
touch touch filename.txt Creates a file called “filename”
mkdir mkdir subfolder
mkdir subfolder1 subfolder2
Create folders
mv mv oldname.txt newname.txt Rename a file
cp cp file.txt PATH Copies a file to the new PATH location
rm rm file.txt Deletes a file

Looking at files

Command Example Detail
cat cat file.txt Prints contents of file to terminal
wc

wc file.txt

wc -l file.txt

Counts number of lines words and characters. -l option only gives number of lines
head head file.txt Shows first few lines of file
nano nano file.txt Opens text editor program
less less file.txt Another text editor program

Resources